<template>
	<view class="page">
		<up-navbar title="销售管理" :autoBack="true" safeAreaInsetTop placeholder> </up-navbar>




		<view style=" margin-bottom: 20rpx;">
			<view class="biejings" v-for="(item, index) in list" :key="index" @click="xiangqing(item.id)">

				<view class="minjs_sf">
					<view style=" display: flex; padding-top: 20rpx; padding-bottom: 20rpx; ">
						<view style="width: 100%; display: flex;height: 140rpx;">
							<view class="neirngssf">
								<image class="icon1" :src="item.avatar" alt="" />
							</view>
							<view class="neirngs" style="width: 39%;">
								<view style="line-height: 87rpx;"><text>{{item.nickname}}</text></view>
								<view><text style="color: #999999;">{{item.username}}</text></view>
							</view>

							<view class="neirngs"
								style="align-items: center; display: flex; justify-content: flex-end;">
								<view style=" display: flex;align-items: center;justify-content: center; ">
									<text style="color: #999999;">查看信息</text>

									<image class="" src="/static/Frameyoux.png" alt=""
										style="width:35rpx;height:35rpx; margin-left: 20rpx;" />

									<!-- <text style="color: #999999;">>></text> -->



								</view>
							</view>
						</view>


					</view>
					<view class="biank">
						<view class=" flex-endf jigsf">
							<view style="display:flex;align-items:center;">
								<image class="" src="/static/xiali.png" alt="" style="width:35rpx;height:35rpx; " />
								<text style=" margin-left: 10rpx;">成交量：</text> <text
									style="color: #FF7139;">{{item.order_num}}</text>
							</view>
							<view style="display:flex;align-items:center;">
								<image class="" src="/static/jine.png" alt="" style="width:35rpx;height:35rpx; " />

								<text style="margin-left: 10rpx;">成交金额：</text> <text
									style="color: #FF7139;">¥{{item.order_money}}</text>
							</view>
						</view>
					</view>
				</view>

			</view>
		</view>
		<!-- position: fixed; bottom: 30rpx; width: 90%; left: 5%; -->
		<view style="  " v-if="user_type==2">
			<view style="width: 90%; margin: 0 auto;  margin-top: 50rpx; margin-bottom: 20rpx; ">
				<view><up-button class="custom-style" shape="circle" color="#FF6A04" text="添加销售"
						@click="baocun"></up-button></view>

			</view>

		</view>



	</view>
</template>

<script>
	import request from '@/utils/request'
	export default {
		data() {
			return {
				// DataList: 'https://cdn.uviewui.com/uview/album/1.jpg',
				page: 1,
				limit: 10,
				list: [],
				user_type:'',

			}
		},
		onShow() {
			this.page=1;
			this.fenhong()
			this.getUserData()
			
		},
		methods: {
			
			getUserData() {
				console.log(121213)
				this.$request({
					url: 'api/User/getUserInfo',
					header: "application/x-www-form-urlencoded",
					data: {}
				}).then(res => {
					if (res.code == 1) {
						console.log(res.data.user_type,'res')
						this.user_type=res.data.user_type
					} 
				})
				
			},
			fenhong() {
				var insg = uni.getStorageSync('userinfo')
					this.user_type=insg.user_type
				console.log(insg, '1111')
				this.$request({
					url: '/api/User/getMySaleLists',
					header: "application/x-www-form-urlencoded",
					data: {
						type: insg.user_type,
						page: this.page,
						limit: this.limit,
					}
				}).then(res => {
					if (res.code == 1) {
						console.log(res)
						res.data.forEach((item, index) => {
							item.avatars=request+item.avatar
						});	
						this.list = res.data
					} else {


					}
				})

			},
			baocun() {
				var data = {
					id: null
				}
				var jisng = encodeURIComponent(JSON.stringify(data))
				uni.navigateTo({

					url: '/pages/my/xiao_liang/add_xiaoliang/add_xiaoliang?options=' + jisng
					// url: '/pages/my/daili_shang/add_daili_s/add_daili_s'
				});

			},
			xiangqing(id) {
				console.log(id)
				uni.navigateTo({

					url: '/pages/my/xiao_liang/xiaoliang_xiangq/xiaoliang_xiangq?id='+id
				});
			},
			onReachBottom() {
				console.log(111)
				var insg = uni.getStorageSync('userinfo')
				var that = this
				uni.showLoading({
					title: '加载中...',
					mask: true //遮蔽层
				})
				console.log(1231123);
				that.page += 1;				
				this.$request({
					url: '/api/User/getMySaleLists',
					header: "application/x-www-form-urlencoded",
					data: {
						type: insg.user_type,
						page: that.page,
						limit: that.limit,
					}
				}).then(res => {
					if (res.code == 1) {
						var feilei_neirong = res.data.forEach((item, index) => {
							item.avatars=request+item.avatar
						});	
						// this.list=res.data
						console.log(res)
						if (feilei_neirong.length != 0) {

							feilei_neirong.forEach(rect => {

								that.list.push(rect);
							});
							console.log(that.list = that.list)

						
							uni.hideLoading()
						} else {
							uni.showToast({
								title: '没有更多的数据了',
								icon: 'none',
								duration: 2000
							});
						}
						
					} else {


					}
				})
			},

		},
		onReachBottom() {
			this.onReachBottom()
		}
	}
</script>

<style lang="scss" scoped>
	.biejings {
		width: 90%;
		margin: 0 auto;
		margin-top: 20rpx;
	}

	.page {
		background: #F8F8F8;
	}

	.yanshi:last-child {
		// border-bottom: 1px solid #ccc; /* 添加下边框 */
		margin-bottom: 150rpx;
		padding-bottom: 150rpx;
	}

	.minjs_sf {
		background-color: #fff;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
	}

	.neirngssf {
		width: 20%;
		padding: 10rpx;
		margin-left: 30rpx;

	}

	.neirngs {
		width: 36%;
		padding: 10rpx;



	}

	.flex-endf {
		display: flex;
		justify-content: space-between;
		;
	}

	.flex-end {
		display: flex;
		justify-content: flex-end;
	}

	.jxzf {
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #FF7139;
		border-radius: 50rpx 0rpx 0rpx 50rpx;
	}

	.icon1 {
		width: 100%;
		height: 100%;
		border-radius: 50%;

	}

	.biank {
		border-top: 1rpx dashed #eee;
		width: 90%;
		margin: 0 auto;
	}

	.jigsf {
		height: 80rpx;
		line-height: 80rpx;
	}
</style>